<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
            <div class="fieldBox" id="searchPrjNmId">
                <div class="label">项目名称</div>
                <div class="field">
                    <input name="prjNm" id="prjNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
           <div class="fieldBox" id="searchCstNmId">
                <div class="label">客户名称</div>
                <div class="field">
                    <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
             <div class="fieldBox" id="searchPrjTypCdId">
              <div class="label">项目类型</div>
                <div class="field">
                <select name="prjTypCd"  id="prjTypCd" >
                 <option value="  " selected="selected">--请选择--</option>
                 <c:forEach items="${projectTypeList}" var="opt">
                  <option value="${opt.key}">${opt.value}</option>
                 </c:forEach>
                </select>
                </div>
            </div>
         <div class="fieldBox" id="searchBizTypCdId">
            <div class="label">业务类型</div>
               <div class="field">
                 <select name="bizTypCd"  id="bizTypCd"  >
                  <option value="  " selected="selected">--请选择--</option>
                <c:forEach items="${bizTypeList}" var="opt">
                 <option value="${opt.key}">${opt.value}</option>
                </c:forEach>
               </select>
               </div>
            </div>
             <div class="fieldBox col_33" id="searchPrjStsCdId">
                   <div class="label">项目状态</div>
                             <div class="field">
                               <select name="prjStsCd"  id="prjStsCd" >
                                <option value="  " selected="selected">--请选择--</option>
                              <c:forEach items="${prjStsList}" var="opt">
                               <option value="${opt.key}">${opt.value}</option>
                              </c:forEach>
                             </select>
                             </div>
                   </div>
             <div class="fieldBox" id="searchLsCntNoId">
                <div class="label">合同号</div>
                <div class="field">
                    <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                </div>
            </div>
                <div class="fieldBox" id="searchBuOrgCdId">
                <div class="label">所属事业部</div>
                <div class="field">
                    <select name="buOrgCd" id="buOrgCd">
                        <option value=" " seleted>请选择</option>
                        <c:forEach items="${orgListList }" var="org">
                        	<c:if test="${currentBuOrgCd == org.key }">
                        		<option value="${org.key }" selected>${org.value }</option>
                        	</c:if>
                        	<c:if test="${currentBuOrgCd != org.key }">
                        		<option value="${org.key }">${org.value }</option>
                        	</c:if>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="clearFix"></div>
            <div class="btnsBox">
               <span id="searchBtn"  class="sq-button sq-button-round">查询</span>
               <span id="clearBtn" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
                <span id="clearBtn" onclick="addIRR();" class="sq-button sq-button-round">重新计算IRR</span>
            </div>
        </div>
    </form>
</div>
<div id="ligergrid1" class="sq-grid"></div> 
</div>

<div id="chooseFlowDIV" style="display:none">
    <div id="ligergrid_flowStart" class="sq-grid"></div>
</div>

<script type="text/javascript">
	var grid = null;
	$(function () {
	    $("#ligergrid1").ligerGrid({
	    	url: '<%=path%>/project/prjbscinfo/initOldList.do',
	    	method : 'get',
	        columns: [
	             { display: '项目名称', name: 'prjNm', align:'left',minWidth: 140 /* ,
	            	render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            			if(value&&value!="null"){
	            		    h+='<a href="javascript:detailBtn(';
	                        h+="'"+rowdata.id+"'";
	                        h+=')">'+value+'</a>'
	            			}
	                        return h;
	            		},
	            	enabledSort:true */}, 
	             { display: '合同号', name: 'lsCntNo', width: 140 , enabledSort:true}, 
	            { display: '客户', name: 'cstNm', width: 100,align:'center', enabledSort:true},
	            { display: '客户经理', name: 'cstMgrNm', width: 100,align:'center', enabledSort:true},
	            /* { display: '所属机构', name: 'buOrgCdNm', width: 100 , enabledSort:true}, */
	            { display: '项目类型', name: 'prjTypCdNm', width: 150, enabledSort:true},
	            { display: '业务模式', name: 'bizTypCdNm', width: 100 , enabledSort:true},
	            { display: '项目状态', name: 'prjStsCdNm', width: 80 , enabledSort:true},
	             /* { display: '申请单号', name: 'pNo', minWidth: 140 , 
	              	render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            			if(value&&value!="null"){
	            		    h+='<a href="javascript:commShowFlow(';
	            		    h+="'"+rowdata.pInstId+"',";
	            		    h+="'"+rowdata.prjStsCd+"',";
	            		    h+="'"+rowdata.id+"'";
	            		    h+=')">'+value+'</a>'
	            			}
	                        return h;
	            		},
	            	enabledSort:true}, 
	            { display: '数据来源', name: 'dsCdNm', minWidth: 100 , enabledSort:true}, */
	            { display: '创建时间', name: 'crtTm', minWidth: 100 , render:renderDate, enabledSort:true},
	            getOptColumn()
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:false,
	        rownumbers:true
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	    $("#searchBar").ligerForm();
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         data["crtTm"] = $("#crtTm").val();
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	
	    $("#pageloading").hide();
	
	});
	
	//获取操作列
	function getOptColumn(){
		var column = {
            display: '操作',
            isSort: false,
            width: 100,
            align:'left',
            render: function (rowdata, rowindex, value){
            	var h="";
                h+='<a target="_blank" class="sq-button-hasicon" href="<%=path%>/project/prjbscinfo/exportInvesstRpt.do?prjId='+rowdata.id+'&&cstId='+rowdata.cstId+'&&cstRlCd=1';
                h+='">导出资信</a>';
                return h;
            }
        }
		return column;
	}
	//显示流程
    function commShowFlow(_pInstId, _audStsCd, _businessKey){
    	if(StringUtils.isEmpty(_pInstId)){
    		UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
    		return;
    	}
    	var _formUrl = "/project/audit/toAdditionalInfoPage.do?isDetail=1"+"@@processInstanceId="+_pInstId+"@@projectId=";
    	var params = "?pInsId="+_pInstId+"&status="+_audStsCd+"&businessKey="+_businessKey+"&formUrl="+_formUrl;
    	Add_navTab('tab_cst_invoice_flow_'+_businessKey,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
    }
	
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	
	function detailBtn(id){
		var fromPrjFlag = true;
		var detailFlag = true;
		
		Add_navTab('tab_project_detail'+id,'项目详情','<%=path%>/project/prjbscinfo/toModifyPage.do?fromPrjFlag='+fromPrjFlag+'&&id='+id+'&&detailFlag='+detailFlag);
	}
  function clearBtn(){
    $("#searchBar").ligerForm();
			var form = new liger.get("searchBar");
			form.setData({
				prjNm:" ",
				cstNm:" ",
				prjTypCd:" ",
				bizTypCd:" ",
				prjStsCd:" ",
				orgCd:" ",
				lsCntNo:" "
			 });
	}
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    }
	}
	function addIRR(){
	     var params = {};
	     $.ajax({
	          type: 'post',
	          dataType:'json',
	          data:params,
	          url: '<%=path%>/project/prjquatprps/addPrpsQuatIRRPct.do',
	          success:function(msg){
	               if(msg.success == 1){
	                    top.$.ligerDialog.SQalert({content:"重新计算成功！",SQ_type: "success"});

	               }else{
	                    top.$.ligerDialog.SQalert({content: "重新计算失败！",SQ_type: "error"});
	               }
	          }
	     });
	}
</script>

</body>
</html>